<template>
    <a-select
            v-bind="$attrs"
            :value="renderValue"
            :filterOption="getFilter"
            showSearch
            allowClear
            @change="onChange">
        <a-select-option :value="item2.dataValue || item2.codeMasterValue" :key="index2"
                         v-for="(item2,index2) in (typeof typeData == 'string'?$store.getters.dictionary[typeData]:typeData)">
            {{item2.dataName || item2.codeMasterName}}
        </a-select-option>
    </a-select>
</template>

<script>
    export default {
        name: "xlSelect",
        data() {
            return {}
        },
        props: {
            value: [String, Number],
            typeData:[String,Array]
        },
        model: {
            prop: 'value',
            event: 'change'
        },
        created(){
          console.log(this.typeData,111)
        },
        methods: {
            getFilter(input, option) {
                return (
                    option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 || option.componentOptions.propsData.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
                );
            },
            onChange(e){
                if(e == undefined){
                    e = ''
                }
                this.$emit('change',e);
            }
        },
        // watch:{
        //     value(){
        //         this.$emit('change',this.value);
        //     }
        // },
        computed: {
            renderValue() {
                return this.value
            }
        }
    }
</script>

<style scoped>

</style>
